<template>
  <div>
    <div class="home-box">
      <div class="home-center">
        <div class="left">
          <img class="logo" src="@/assets/image/logo.png" alt="">
          <p class="title">缘分在这里，真心遇见。携手同行，创造属于我们的美好未来。</p>
          <p class="content">在相亲的过程中，保持真诚与耐心，让每一次相遇都充满希望。</p>
          <div class="btn">
<!--            <a href="javascript:void (0)" v-routers="{path:'/login'}">登录/注册</a>-->
          </div>
        </div>
        <div class="right">
          <lz-home></lz-home>
        </div>
      </div>
    </div>
    <div class="home-box box-nav-list">
      <div class="home0-center">
        <div class="item">
            <div class="nav-box">
              <img src="@/assets/image/1.webp" alt="">
            </div>
          <div class="title">
            专注缘分交友十年
          </div>
          <div class="box-center">
            我们成立于2010年 <br>
            深耕十年，用户沉淀厚实
          </div>
        </div>
        <div class="item">
          <div class="nav-box">
            <img src="@/assets/image/2.webp" alt="">
          </div>
          <div class="title">
            注册突破千万会员
          </div>
          <div class="box-center">
            截2019年12月 <br>
            会员注册量突破1000多万
          </div>
        </div>
        <div class="item">
          <div class="nav-box">
            <img src="@/assets/image/3.webp" alt="">
          </div>
          <div class="title">
            覆盖超过537个城市
          </div>
          <div class="box-center">
            在全国会员覆盖面积 <br>
            已超过537个一二线城市
          </div>
        </div>
        <div class="item">
          <div class="nav-box">
            <img src="@/assets/image/4.webp" alt="">
          </div>
          <div class="title">
            实力品牌保障服务
          </div>
          <div class="box-center">
            好评口碑实力老品牌 <br>
            是行业内的知名中小企业
          </div>
        </div>
      </div>
    </div>

    <div class="home-box box-3-list" v-if="userList.length>0">
      <div class="center-box1">
          <div class="box-title-1">
            <img src="@/assets/image/5.webp" alt="">
            <div class="center">
                <p>红娘推荐优质会员</p>
                <p>TA们都在寻爱，你还在等什么？</p>
            </div>
          </div>
          <div class="box-2-nav">
            <div v-for="(item,index) in userList" v-loading="loading" :key="index" class="box-item">
              <img class="image" :src="item.icon" alt="">
              <div class="nav">
                <span class="left-icon">
                  <i class="el-icon-s-opportunity"></i> {{ item.realName }}
                </span>
                <span class="left-icon">
                    {{item.birthday ? parseTime(item.birthday) : '暂无数据'}}
                </span>
              </div>
              <div class="nav">
                <span class="left-icon">
                  <i class="el-icon-location"></i> {{item.remake}}
                </span>
                <span class="left-icon">
                  {{item.note}}元/月
                </span>
              </div>
              <div class="nav-content">
                {{ item.habits }}
              </div>

              <a class="btn" @click="submitFormMessage(item)" href="javascript:void (0)">给TA发消息</a>
            </div>

          </div>
      </div>
    </div>

    <div class="home-box box-3-list" v-if="activityList.length>0">
      <div class="center-box1">
        <div class="box-title-1">
          <img src="@/assets/image/5.webp" alt="">
          <div class="center">
            <p>线下相亲会</p>
            <p>TA们都在寻爱，你还在等什么？</p>
          </div>
        </div>
        <div class="box-2-nav" style="justify-content: space-between">
            <div class="box-item-length" v-for="(item,index) in activityList" :key="index">
              <img
                  class="img-left"
                  :src="item.cover"
                  alt="">
              <div class="right-box">
                <p class="titles over-hide-1">
                  {{ item.title }}
                </p>
                <p class="time">报名时间：{{ item.beginTime ? parseTime(item.beginTime) : '暂无数据'}}</p>
                <p class="time">报名时间：{{ item.endTime ? parseTime(item.endTime) : '暂无数据'}}</p>
                <p class="time"> 活动地址：{{ item.address }}</p>
                <a class="btn-bot" style="background: #42b983" v-if="item.IsApplication === 1" href="javascript:void (0)">已参与</a>
                <a class="btn-bot" v-else @click="onSubmit(item)" href="javascript:void (0)">我要报名</a>

              </div>
            </div>
        </div>
      </div>
    </div>

    <el-dialog :visible.sync="dialogVisible" width="850px" :before-close="handleClose">
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="您的姓名">
          <el-input v-model="form.eventName" placeholder="请输入您的姓名"></el-input>
        </el-form-item>
        <el-form-item label="联系电话">
          <el-input v-model="form.name" placeholder="请输入联系电话"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="danger" @click="onSubmit">立即提交</el-button>
          <el-button>取消提交</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <lz-footer></lz-footer>
    <lz-login :is-show="isLogin"></lz-login>
  </div>
</template>

<script>

import {followMembers, getAllUser, getDatEventList, participateInActivities} from "@/api/apiFox";
  import {parseTime} from "@/utils";

  export default {

    data(){
      return{
        dialogVisible:false,
        isLogin:false,
        loading:false,
        imageUrl: '',
        userList:[],
        activityList:[],
        form: {
          eventName:"",

        }
      }
    },
    methods:{
      parseTime,
      handleClose(){
        this.dialogVisible=false
      },
      onSubmit(item){
        console.log(item)
        this.$confirm('是否参与此活动', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          participateInActivities({eventId:item.id,eventName:item.eventName}).then(res=>{
            this.$message.success('参与成功')
          }).catch(err=>{})
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          });
        });
      },

      getList(){
        getAllUser({role:2,pageSize:20,pageNum:1}).then(res=>{
          this.userList = res.list
        }).catch(err=>{})

        getDatEventList({pageSize:20,pageNum:1}).then(res=>{
          this.activityList = res.list
        }).catch(err=>{})
      },

      submitFormMessage(item){
        console.log(item)
        this.loading=true
        followMembers({userId:item.id}).then(res=>{
          this.$message.success('已关注')
          this.loading=false
          setTimeout(()=>{
            this.$router.push({path:'/chat',query:{id:item.id}}).catch(err=>{})
          },1000)

        }).catch(err=>{})
      }
    },

    mounted() {
      this.getList()
    }
  }
</script>

<style scoped lang="scss">
  .home-box{
    width: 100%;
    min-height: calc(100vh - 140px);
    background:var(--homeBgk);
    display: flex;
    justify-content: center;
    .home-center{
      width: 1200px;
      min-height: calc(100vh - 140px);
      display: flex;
      justify-content: space-between;
      //background: #fff;
      .left{
        width: 600px;
        padding-top: 20vh;
        box-sizing: border-box;
        .logo{
          margin: 10px 0;
        }
        .title{
          font-size: 36px;
          font-weight: 400;
          //text-align: center;
          color: var(--textColor);
        }
        .content{
          font-size: 14px;
          margin-top: 15px;
          color: var(--colorTip);
        }
        .btn{
          width: 100%;
          margin-top: 30px;
          a{
            display: flex;
            align-items: center;
            justify-content: center;
            width: 150px;
            font-size: 16px;
            height: 45px;
            color: #fff;
            background: #333;
            border-radius: 10px;
          }
        }
      }
      .right{
        width: 800px;
        margin-right: -200px;
      }
    }
  }
  .box-nav-list{
    background: var(--navBgk);
    height: 200px !important;
    margin-bottom: -200px;
    .home0-center{
      width: 1200px;
      padding-top: 120px;
      display: flex;
      height: 200px;
      justify-content: space-between;
      .item{
        width: 300px;
        height: 300px;
        text-align: center;
        .nav-box{
          width: 100%;
          height: 120px;
          border-radius: 50%;
          img{
            width: 100px;
            height: 100px;
            object-fit: cover;
          }
        }
        .title{
          font-size: 22px;
          color: var(--textColor);
          font-weight: 600;
        }
        .box-center{
          margin-top: 15px;
          font-size: 12px;
          color: var(--colorTip);
        }
      }
    }
  }
  .box-3-list{
    width: 100%;
    background: var(--navBgk);
    padding-bottom: 150px;
    padding-top: 45px;
    .center-box1{
      width: 1200px;
      .box-title-1{
        width: 100%;
        text-align: center;
        position: relative;
        .center{
          width: 100%;
          position: absolute;
          margin-top: -30px;
          p:nth-child(1){
            font-size: 28px;
            font-weight: 600;
            color: #fc476d;
          }
          p:nth-child(2){
            font-size: 12px;
            color: var(--colorTip);
          }
        }
      }
      .box-2-nav{
        width: 100%;
        margin-top: 100px;
        display: flex;
        //justify-content: space-between;
        flex-wrap: wrap;
        .box-item{
          margin-bottom: 25px;
          width: 278px;
          min-height: 480px;
          margin-right: 20px;
          background: var(--itemBgk);
          //border-radius: 10px;
          overflow: hidden;
          padding: 10px;
          box-sizing: border-box;
          box-shadow: rgba(149, 157, 165, 0.2) 0px 8px 24px;
          .image{
            width: 100%;
            height: 250px;
            object-fit: cover;
          }
          .nav{
            width: 100%;
            margin-top: 15px;
            display:  flex;
            justify-content: space-between;
            .left-icon{
              font-size: 14px;
              color: var(--navCircle);
              i{
                color: #fc476d;
              }
            }
          }
          .nav-content{
            font-size: 14px;
            margin-top: 10px;
            color: var(--colorTip);
          }
          .btn{
            width: 100%;
            height: 40px;
            display: flex;
            justify-content: center;
            margin-top: 18px;
            align-items: center;
            font-size: 14px;
            border: 1px solid var(--switchBorder);
            color: var(--activeColor);
          }
        }
        .box-item-length{
          width: 48%;
          margin: 10px 0;
          min-height: 150px;
          padding: 10px;
          background: var(--itemBgk);
          box-sizing: border-box;
          display: flex;
          justify-content: space-between;
          box-shadow: rgba(149, 157, 165, 0.2) 0px 8px 24px;
          .img-left{
            width: 220px;
            height: 220px;
            object-fit: cover;
          }
          .right-box{
            width: calc(100% - 220px);
            margin-left: 15px;
            padding-top: 15px;
            box-sizing: border-box;
            .titles{
              font-weight: 600;
              font-size: 18px;
              color: var(--navCircle);
            }
            .time{
              font-size: 16px;
              color: var(--navCircle);
              margin-top: 10px;
            }
            .btn-bot{
              margin-top: 20px;
              width: 200px;
              height: 42px;
              border-radius: 5px;
              background: var(--activeColor);
              color: var(--navBgk);
              font-size: 14px;
              display: flex;
              justify-content: center;
              align-items: center;
            }
          }
        }
      }
    }
  }
</style>
